﻿using System.Threading;
using System.Web.Mvc;
using Domain.Test;
using Infrastructure;

namespace GrandCWeb.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            return View();
        }

		[HttpGet]
		public ActionResult AllRules()
		{
			var repo = new RuleRepo();
			var program = new GrandCentral(repo);
			program.When(new InputButton().Is_Pressed).Then(new Listener().Should_Toggle);
			var result =  Json(repo.All(),JsonRequestBehavior.AllowGet);
			return result;
		}

		[HttpPost]
		public void Add(string name,int money)
		{
			var p = new Person() {Name = name, Money = money};
			
			MyDataBase.Save(p,"xxx");
			//todo
		}

		[HttpGet]
		public ActionResult Read(string name)
		{
			//MyDataBase.Read<Person>()
			var something = MyDataBase.Read(name);
			return Json(something, JsonRequestBehavior.AllowGet);
		}

		[HttpGet]
		public string AllRules2()
		{
			Thread.Sleep(2000);
			var str = "test";
			return str;
		}

    }

	
}
